import sys
class Polynomials(object):
	"""docstring for Polynomials"""
	def __init__(self, input):
		super(Polynomials, self).__init__()
		self.number = int(input[0])
		self.highest = int(input[1])
		self.exponets = [0 for i in range(self.highest + 1)]
		for x in range(self.number):
			self.exponets[int(input[2 * x + 1]) ] = input[2 * x + 2]
			pass
	def write(self):
		out =  str(self.number)
		res = self.exponets[::-1]
		for i in range(len(res)):
			if res[i] != 0:
				out+= ' ' + str(len(res)-i-1) + ' '+ str(res[i])
		print out
	def add(self,x):
		smaller = []
		larger = []
		if self.highest > x.highest:
			larger = self.exponets[::]
			smaller = x.exponets[::]
		else:
			smaller = self.exponets[::]
			larger = x.exponets[::]
		for i in range(len(smaller)):
			larger[i] += smaller[i]
		self.exponets = larger
		self.number = 0
		for i in range(len(larger)):
			if larger[i] != 0:
				self.number += 1
		self.highest = len(larger)
		pass	


def main():
	l0 = map(float,sys.stdin.readline().split())
	l1 = Polynomials( map(float,sys.stdin.readline().split()))
	# test = Polynomials([2,1,2.4,0,3.2])
	# test1 = Polynomials([3,5,0.6,2,1.5,1,0.5])
	l0.add(l1)
	l0.write()
	# l1 = map(float,sys.stdin.readline().split())  
	pass
if __name__ == '__main__':
	main()